﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace Validation
{
    public class GUIValidator : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
           if ((value as string).Length < 5)
            {
                return new ValidationResult(false, "Illegal characters or ");
            }
            return new ValidationResult(true, null);
        }
    }

    public class MaNhanVienValidtor : ValidationRule
    {
        public static int Min = 5;
        public static int Max = 10;
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if ((value as string).Length < Min || (value as string).Length > Max)
            {
                return new ValidationResult(false, "Mã giáo viên phải lớn hơn " + Min + " và nhỏ hơn " + Max);
            }
            return new ValidationResult(true, null);
        }
    }

    public class HoTenValidtor : ValidationRule
    {
        public static int Min = 3;
        public static int Max = 100;
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if ((value as string).Length < Min || (value as string).Length > Max)
            {
                return new ValidationResult(false, "Họ tên phải lớn hơn " + Min + " và nhỏ hơn " + Max);
            }
            return new ValidationResult(true, null);
        }
    }

    public class CMNDValidtor : ValidationRule
    {
        public static int Min = 9;
        public static int Max = 12;
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if ((value as string).Length < Min || (value as string).Length > Max)
            {
                return new ValidationResult(false, "CMND phải lớn hơn " + Min + " và nhỏ hơn " + Max);
            }
            return new ValidationResult(true, null);
        }
    }

    public class QueQuanValidtor : ValidationRule
    {
        public static int Min = 1;
        public static int Max = 200;
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if ((value as string).Length < Min || (value as string).Length > Max)
            {
                return new ValidationResult(false, "Quê quán phải lớn hơn " + Min + " và nhỏ hơn " + Max);
            }
            return new ValidationResult(true, null);
        }
    }

    public class DiaChiValidtor : ValidationRule
    {
        public static int Min = 1;
        public static int Max = 200;
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if ((value as string).Length < Min || (value as string).Length > Max)
            {
                return new ValidationResult(false, "Địa chỉ phải lớn hơn " + Min + " và nhỏ hơn " + Max);
            }
            return new ValidationResult(true, null);
        }
    }
}
